<template>
	<div class="tongzhi">
    <left></left>
    <div class="right">
      <div style="height: 91px; border-bottom: 1px solid rgb(227, 232, 241); width: 100%; padding: 0 30px;" class="flexbc">
        <div class="flexcc fanhui" @click="back">
          <div><i class="el-icon-arrow-left" style="margin-right: 5px;"></i></div>
          <div>返回</div>
        </div>
        <top></top>
      </div>
      <div style="padding: 37px 30px 0 30px; height: calc(100vh - 91px); overflow: auto;">

        <el-table :data="list" style="width: 100%">
          <el-table-column align="center" prop="title" label="标题"></el-table-column>
          <el-table-column align="center" prop="version" label="版本号"></el-table-column>
          <el-table-column align="center" prop="created_at" label="发布时间"></el-table-column>
          <el-table-column align="center" prop="release_name" label="发布人"></el-table-column>
          <el-table-column align="center" prop="ok_count" label="操作">
            <template slot-scope="scope">
              <div class="flexcc">
                <div style="color: rgb(0, 90, 255); cursor: pointer; margin-right: 20px;" @click="xiangqing(scope.row)">详情></div>
              </div>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination style="text-align: right; padding: 20px;" background layout="prev,pager,next,total,jumper" :current-page="search.page"
         @current-change="fanye" :page-size="search.page_size" :total="total"></el-pagination>
      </div>
    </div>


    <el-dialog title="通知详情" :visible.sync="log2" :close-on-click-modal="false" :close-on-press-escape="false" width="800px">
      <div>
        <div style="margin-bottom: 20px;"><span style="font-weight: bold; margin-right: 10px;">通知标题:</span>{{now.title}}</div>
        <div style="margin-bottom: 20px;"><span style="font-weight: bold; margin-right: 10px;">版本号:</span>{{now.version}}</div>
        <div style="margin-bottom: 20px;"><span style="font-weight: bold; margin-right: 10px;">上线时间:</span>{{now.release_at}}</div>
        <div style="margin-bottom: 20px;" v-html="now.content"></div>
        <div style="margin-bottom: 20px;" class="flexc" v-if="now.annex"><span style="font-weight: bold; margin-right: 10px;">附件:</span>
          <div @click="xiazai(now.annex)" style="color: rgb(0, 90, 255); cursor: pointer; margin-right: 20px;">下载</div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="log2 = false">关闭</el-button>
      </span>
    </el-dialog>


	</div>
</template>

<script>
  import left from '../left.vue'
  import top from '../top.vue'
  import footers from '../footer.vue'
  import fuwenben from '@/components/fuwenben.vue'
	export default {
		name: 'tongzhi',
    components:{
      left,top,fuwenben,footers
    },
		data() {
			return {
        tongzhi:{},
        log2:false,
        now:"",
        relo:false,
        log:false,
        search:{
          page:1,
          page_size:20,
        },
        list:[],
        total:0,
			}
		},
		created() {
      //列表
      this.getlist()

		},
		mounted() {

		},
		methods: {
      xiazai:function(url){
        window.location.href = url  + '?attname='
      },
      xiangqing:function(item){
        this.now = item
        this.log2 = true
      },
      logshow:function(item){
        if(item){
          this.tongzhi = {
            id:item.id,
            title:item.title,
            content:item.content,
            version:item.version
          }
        }else{
          this.tongzhi = {
            id:"",
            title:"",
            content:"",
            version:""
          }
        }
        this.log = true
        this.$nextTick(()=>{
          this.relo = true
        })
      },

      getcontent:function(item){
        this.tongzhi.content = item
      },

      xiugai:function(){
        axios.post('/plat/sys/version/update',this.tongzhi).then((response)=>{
        	if (response.data.msg.code == 0) {
            this.getlist()
            this.log = false
        	} else {
        		this.$message.error(response.data.msg.info);
        	}
        })
      },
      //列表
      getlist:function(){
        axios.get('/api/sys/version/list').then((response)=>{
        	if (response.data.msg.code == 0) {
            this.list = response.data.data.data

            this.total = response.data.data.total
        	} else {
        		this.$message.error(response.data.msg.info);
        	}
        })
      },
      fanye:function(val){
        this.search.page = val
        this.getlist()
      },
      //删除
      delbtn(item){
        this.$confirm('是否确认删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          axios.post('/plat/sys/version/del',{
            id:item.id
          }).then((response)=>{
            if (response.data.msg.code == 0) {
              this.$message({
                type: 'success',
                message: '操作成功!'
              });
              this.getlist()
            } else {
              this.$message.error(response.data.msg.info);
            }
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消'
          });
        });
      }
		}
	}
</script>


<style scoped >
 .t_over_text{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: calc(100% - 40px);
 }
</style>
